package com.example.jetpacktest.network

import com.example.jetpacktest.domain.Student
import com.example.jetpacktest.network.api.RetrofitTest1Api
import java.lang.Exception

class RetrofitTest1Network {

    private val api: RetrofitTest1Api by lazy {
        RetrofitSingleTon.getRetrofitInstance().create(RetrofitTest1Api::class.java)
    }


    suspend fun getStudent(id: Long): Student{
        try{
            return api.getStudent(id)
        }catch (ex: Exception){
            ex.printStackTrace()
            throw Exception("网络请求获取Student发生了异常: ${ex.message}")
        }
    }


}